package com.jk.myimkit.imkit;

import android.app.Application;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.jk.myimkit.R;
import com.jk.myimkit.eventbus.EventBus;
import com.jk.myimkit.imageloader.core.DisplayImageOptions;
import com.jk.myimkit.imageloader.core.ImageLoader;
import com.jk.myimkit.imageloader.core.assist.FailReason;
import com.jk.myimkit.imageloader.core.assist.ImageSize;
import com.jk.myimkit.imageloader.core.listener.ImageLoadingListener;
import com.jk.myimkit.imageloader.core.listener.ImageLoadingProgressListener;
import com.jk.myimkit.imkit.manager.AudioRecordManager;
import com.jk.myimkit.imkit.manager.IUnReadMessageObserver;
import com.jk.myimkit.imkit.manager.InternalModuleManager;
import com.jk.myimkit.imkit.manager.SendImageManager;
import com.jk.myimkit.imkit.manager.UnReadMessageManager;
import com.jk.myimkit.imkit.mention.RongMentionManager;
import com.jk.myimkit.imkit.model.ConversationKey;
import com.jk.myimkit.imkit.model.Event;
import com.jk.myimkit.imkit.model.GroupUserInfo;
import com.jk.myimkit.imkit.model.UIConversation;
import com.jk.myimkit.imkit.notification.MessageNotificationManager;
import com.jk.myimkit.imkit.plugin.image.AlbumBitmapCacheHelper;
import com.jk.myimkit.imkit.userInfoCache.RongUserInfoManager;
import com.jk.myimkit.imkit.utils.SystemUtils;
import com.jk.myimkit.imkit.widget.provide.CSPullLeaveMsgItemProvider;
import com.jk.myimkit.imkit.widget.provide.DiscussionNotificationMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.FileMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.GroupNotificationMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.HandshakeMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.IContainerItemProvider;
import com.jk.myimkit.imkit.widget.provide.ImageMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.InfoNotificationMsgItemProvider;
import com.jk.myimkit.imkit.widget.provide.LocationMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.PublicServiceMultiRichContentMessageProvider;
import com.jk.myimkit.imkit.widget.provide.PublicServiceRichContentMessageProvider;
import com.jk.myimkit.imkit.widget.provide.RealTimeLocationMessageProvider;
import com.jk.myimkit.imkit.widget.provide.RecallMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.RichContentMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.TextMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.UnknownMessageItemProvider;
import com.jk.myimkit.imkit.widget.provide.VoiceMessageItemProvider;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import io.rong.common.RLog;

import io.rong.imlib.AnnotationNotFoundException;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.MessageTag;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.RongIMClient.ErrorCode;
import io.rong.imlib.model.CSCustomServiceInfo;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Discussion;
import io.rong.imlib.model.Group;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.MessageContent;
import io.rong.imlib.model.PublicServiceProfile;
import io.rong.imlib.model.PublicServiceProfileList;
import io.rong.imlib.model.UserData;
import io.rong.imlib.model.UserInfo;
import io.rong.message.InformationNotificationMessage;
import io.rong.message.LocationMessage;
import io.rong.message.RecallNotificationMessage;
import io.rong.push.RongPushClient;

public class RongIM {
    private static final String TAG = RongIM.class.getSimpleName();
    private static final int ON_SUCCESS_CALLBACK = 100;
    private static final int ON_PROGRESS_CALLBACK = 101;
    private static final int ON_CANCEL_CALLBACK = 102;
    private static final int ON_ERROR_CALLBACK = 103;
    private static Context mContext;
    static RongIMClient.OnReceiveMessageListener sMessageListener;
    static RongIMClient.ConnectionStatusListener sConnectionStatusListener;
    private static RongIM.MessageInterceptor messageInterceptor;
    private RongIMClientWrapper mClientWrapper;
    private static boolean notificationQuiteHoursConfigured;
    private static RongIMClient.ConnectionStatusListener mConnectionStatusListener = new RongIMClient.ConnectionStatusListener() {
        public void onChanged(RongIMClient.ConnectionStatusListener.ConnectionStatus status) {
            if (status != null) {
                RLog.d(RongIM.TAG, "ConnectionStatusListener onChanged : " + status.toString());
                if (RongIM.sConnectionStatusListener != null) {
                    RongIM.sConnectionStatusListener.onChanged(status);
                }

                if (status.equals(ConnectionStatus.DISCONNECTED)) {
                    SendImageManager.getInstance().reset();
                }

                if (status.equals(ConnectionStatus.CONNECTED) && !RongIM.notificationQuiteHoursConfigured) {
                    RLog.d(RongIM.TAG, "ConnectionStatusListener not get notificationQuietHours, get again");
                    RongIM.SingletonHolder.sRongIM.getNotificationQuietHours((RongIMClient.GetNotificationQuietHoursCallback)null);
                }

                RongContext.getInstance().getEventBus().post(status);
            }

        }
    };

    private RongIM() {
        this.mClientWrapper = new RongIMClientWrapper();
    }

    private static void saveToken(String token) {
        SharedPreferences preferences = mContext.getSharedPreferences("RongKitConfig", 0);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("token", token);
        editor.commit();
    }

    private void initSDK(Context context, String appKey) {
        String current = SystemUtils.getCurProcessName(context);
        String mainProcessName = context.getPackageName();
        if (!mainProcessName.equals(current)) {
            RLog.w(TAG, "Init. Current process : " + current);
        } else {
            RLog.i(TAG, "init : " + current);
            mContext = context;
            RongContext.init(context);
            RongConfigurationManager.init(context);
            RongMessageItemLongClickActionManager.getInstance().init();
            initListener();
            if (TextUtils.isEmpty(appKey)) {
                try {
                    ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
                    appKey = applicationInfo.metaData.getString("RONG_CLOUD_APP_KEY");
                    if (TextUtils.isEmpty(appKey)) {
                        throw new IllegalArgumentException("can't find RONG_CLOUD_APP_KEY in AndroidManifest.xml.");
                    }
                } catch (PackageManager.NameNotFoundException var6) {
                    var6.printStackTrace();
                    throw new ExceptionInInitializerError("can't find packageName!");
                }
            }

            RongUserInfoManager.getInstance().init(mContext, appKey, new RongUserCacheListener());
            RongIMClient.init(context, appKey);
            registerMessageTemplate(new TextMessageItemProvider());
            registerMessageTemplate(new ImageMessageItemProvider());
            registerMessageTemplate(new LocationMessageItemProvider());
            registerMessageTemplate(new VoiceMessageItemProvider(context));
            registerMessageTemplate(new DiscussionNotificationMessageItemProvider());
            registerMessageTemplate(new InfoNotificationMsgItemProvider());
            registerMessageTemplate(new RichContentMessageItemProvider());
            registerMessageTemplate(new PublicServiceMultiRichContentMessageProvider());
            registerMessageTemplate(new PublicServiceRichContentMessageProvider());
            registerMessageTemplate(new HandshakeMessageItemProvider());
            registerMessageTemplate(new RecallMessageItemProvider());
            registerMessageTemplate(new FileMessageItemProvider());
            registerMessageTemplate(new GroupNotificationMessageItemProvider());
            registerMessageTemplate(new RealTimeLocationMessageProvider());
            registerMessageTemplate(new UnknownMessageItemProvider());
            registerMessageTemplate(new CSPullLeaveMsgItemProvider());
            RongExtensionManager.init(context, appKey);
            RongExtensionManager.getInstance().registerExtensionModule(new DefaultExtensionModule());
            InternalModuleManager.init(context);
            InternalModuleManager.getInstance().onInitialized(appKey);
            AlbumBitmapCacheHelper.init(context);
        }
    }

    public static void init(Application application, String appKey) {
        RongIM.SingletonHolder.sRongIM.initSDK(application, appKey);
    }

    public static void init(Context context, String appKey) {
        RongIM.SingletonHolder.sRongIM.initSDK(context, appKey);
    }

    public static void init(Context context) {
        RongIM.SingletonHolder.sRongIM.initSDK(context, (String)null);
    }

    public static void registerMessageType(Class<? extends MessageContent> messageContentClass) {
        if (RongContext.getInstance() != null) {
            try {
                RongIMClient.registerMessageType(messageContentClass);
            } catch (AnnotationNotFoundException var2) {
                var2.printStackTrace();
            }
        }

    }

    public static void registerMessageTemplate(IContainerItemProvider.MessageProvider provider) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().registerMessageTemplate(provider);
        }

    }

    public void setCurrentUserInfo(UserInfo userInfo) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setCurrentUserInfo(userInfo);
        }

    }

    public static RongIM connect(final String token, final RongIMClient.ConnectCallback callback) {
        if (RongContext.getInstance() == null) {
            RLog.e(TAG, "connect should be called in main process.");
            return RongIM.SingletonHolder.sRongIM;
        } else {
            saveToken(token);
            RongIMClient.connect(token, new RongIMClient.ConnectCallback() {
                public void onSuccess(String userId) {
                    if (callback != null) {
                        callback.onSuccess(userId);
                    }

                    RongContext.getInstance().getEventBus().post(Event.ConnectEvent.obtain(true));
                    RongExtensionManager.getInstance().connect(token);
                    InternalModuleManager.getInstance().onConnected(token);
                    if (!RongIM.notificationQuiteHoursConfigured) {
                        RongIM.SingletonHolder.sRongIM.getNotificationQuietHours((RongIMClient.GetNotificationQuietHoursCallback)null);
                    }

                }

                public void onError(RongIMClient.ErrorCode e) {
                    if (callback != null) {
                        callback.onError(e);
                    }

                    RongExtensionManager.getInstance().connect(token);
                    InternalModuleManager.getInstance().onConnected(token);
                    RongContext.getInstance().getEventBus().post(Event.ConnectEvent.obtain(false));
                }

                public void onTokenIncorrect() {
                    if (callback != null) {
                        callback.onTokenIncorrect();
                    }

                }
            });
            return RongIM.SingletonHolder.sRongIM;
        }
    }

    private static void initListener() {
        RongIMClient.setOnReceiveMessageListener(new RongIMClient.OnReceiveMessageListener() {
            public boolean onReceived(Message message, int left) {
                boolean isProcess = false;
                if (RongIM.sMessageListener != null) {
                    isProcess = RongIM.sMessageListener.onReceived(message, left);
                }

                MessageTag msgTag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                if (msgTag == null || msgTag.flag() != 3 && msgTag.flag() != 1) {
                    if (!isProcess) {
                        if (message.getMessageId() > 0) {
                            RongContext.getInstance().getEventBus().post(new Event.OnReceiveMessageEvent(message, left));
                        } else {
                            RongContext.getInstance().getEventBus().post(new Event.MessageLeftEvent(left));
                        }
                    }
                } else {
                    if (RongIM.messageInterceptor != null) {
                        boolean msgRemove = RongIM.messageInterceptor.intercept(message);
                        if (msgRemove) {
                            return true;
                        }
                    }

                    RongContext.getInstance().getEventBus().post(new Event.OnReceiveMessageEvent(message, left));
                    if (message.getContent() != null && message.getContent().getUserInfo() != null) {
                        RongUserInfoManager.getInstance().setUserInfo(message.getContent().getUserInfo());
                    }

                    if (isProcess || message.getSenderUserId().equals(RongIM.getInstance().getCurrentUserId())) {
                        return true;
                    }

                    MessageNotificationManager.getInstance().notifyIfNeed(RongContext.getInstance(), message, left);
                    if (left == 0 && !RongIM.notificationQuiteHoursConfigured) {
                        RLog.d(RongIM.TAG, "OnReceiveMessageListener not get notificationQuietHours get again");
                        RongIM.SingletonHolder.sRongIM.getNotificationQuietHours((RongIMClient.GetNotificationQuietHoursCallback)null);
                    }
                }

                RongExtensionManager.getInstance().onReceivedMessage(message);
                return false;
            }
        });
        boolean readRec = false;

        try {
            readRec = RongContext.getInstance().getResources().getBoolean(R.bool.rc_read_receipt);
        } catch (Resources.NotFoundException var4) {
            RLog.e(TAG, "rc_read_receipt not configure in rc_config.xml");
            var4.printStackTrace();
        }

        if (readRec) {
            RongIMClient.setReadReceiptListener(new RongIMClient.ReadReceiptListener() {
                public void onReadReceiptReceived(Message message) {
                    RongContext.getInstance().getEventBus().post(new Event.ReadReceiptEvent(message));
                }

                public void onMessageReceiptRequest(Conversation.ConversationType type, String targetId, String messageUId) {
                    RongContext.getInstance().getEventBus().post(new Event.ReadReceiptRequestEvent(type, targetId, messageUId));
                }

                public void onMessageReceiptResponse(Conversation.ConversationType type, String targetId, String messageUId, HashMap<String, Long> respondUserIdList) {
                    RongContext.getInstance().getEventBus().post(new Event.ReadReceiptResponseEvent(type, targetId, messageUId, respondUserIdList));
                }
            });
        }

        boolean syncReadStatus = false;

        try {
            syncReadStatus = RongContext.getInstance().getResources().getBoolean(R.bool.rc_enable_sync_read_status);
        } catch (Resources.NotFoundException var3) {
            RLog.e(TAG, "rc_enable_sync_read_status not configure in rc_config.xml");
            var3.printStackTrace();
        }

        if (syncReadStatus) {
            RongIMClient.getInstance().setSyncConversationReadStatusListener(new RongIMClient.SyncConversationReadStatusListener() {
                public void onSyncConversationReadStatus(Conversation.ConversationType type, String targetId) {
                    RongContext.getInstance().getEventBus().post(new Event.SyncReadStatusEvent(type, targetId));
                }
            });
        }

        RongIMClient.setOnRecallMessageListener(new RongIMClient.OnRecallMessageListener() {
            public boolean onMessageRecalled(Message message, RecallNotificationMessage recallNotificationMessage) {
                RongContext.getInstance().getEventBus().post(new Event.RemoteMessageRecallEvent(message.getMessageId(), message.getConversationType(), recallNotificationMessage, true, message.getTargetId()));
                MessageTag msgTag = (MessageTag)recallNotificationMessage.getClass().getAnnotation(MessageTag.class);
                if (msgTag != null && (msgTag.flag() == 3 || msgTag.flag() == 1) && RongIM.notificationQuiteHoursConfigured) {
                    MessageNotificationManager.getInstance().notifyIfNeed(RongContext.getInstance(), message, 0);
                }

                return true;
            }
        });
        RongIMClient.setConnectionStatusListener(mConnectionStatusListener);
    }

    public static void setOnReceiveMessageListener(RongIMClient.OnReceiveMessageListener listener) {
        RLog.i(TAG, "RongIM setOnReceiveMessageListener");
        sMessageListener = listener;
    }

    public static void setConnectionStatusListener(RongIMClient.ConnectionStatusListener listener) {
        sConnectionStatusListener = listener;
    }

    /** @deprecated */
    @Deprecated
    public RongIMClientWrapper getRongIMClient() {
        return this.mClientWrapper;
    }

    /** @deprecated */
    @Deprecated
    public void disconnect(boolean isReceivePush) {
        RongIMClient.getInstance().disconnect(isReceivePush);
    }

    public void logout() {
        String current = SystemUtils.getCurProcessName(mContext);
        String mainProcessName = mContext.getPackageName();
        if (!mainProcessName.equals(current)) {
            RLog.w(TAG, "only can logout in main progress! current process is:" + current);
        } else {
            RongContext.getInstance().clearConversationNotifyStatusCache();
            RongIMClient.getInstance().logout();
            RongUserInfoManager.getInstance().uninit();
            UnReadMessageManager.getInstance().clearObserver();
            RongExtensionManager.getInstance().disconnect();
            notificationQuiteHoursConfigured = false;
            MessageNotificationManager.getInstance().clearNotificationQuietHours();
        }
    }

    public void setGroupMembersProvider(RongIM.IGroupMembersProvider groupMembersProvider) {
        RongMentionManager.getInstance().setGroupMembersProvider(groupMembersProvider);
    }

    public static void setLocationProvider(RongIM.LocationProvider locationProvider) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setLocationProvider(locationProvider);
        }

    }

    public void disconnect() {
        RongIMClient.getInstance().disconnect();
        RongExtensionManager.getInstance().disconnect();
    }

    public static RongIM getInstance() {
        return RongIM.SingletonHolder.sRongIM;
    }

    /** @deprecated */
    @Deprecated
    public void startConversationList(Context context) {
        if (context == null) {
            throw new IllegalArgumentException();
        } else if (RongContext.getInstance() == null) {
            throw new ExceptionInInitializerError("RongCloud SDK not init");
        } else {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversationlist").build();
            context.startActivity(new Intent("android.intent.action.VIEW", uri));
        }
    }

    public void startConversationList(Context context, Map<String, Boolean> supportedConversation) {
        if (context == null) {
            throw new IllegalArgumentException();
        } else if (RongContext.getInstance() == null) {
            throw new ExceptionInInitializerError("RongCloud SDK not init");
        } else {
            Uri.Builder builder = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversationlist");
            if (supportedConversation != null && supportedConversation.size() > 0) {
                Set<String> keys = supportedConversation.keySet();
                Iterator var5 = keys.iterator();

                while(var5.hasNext()) {
                    String key = (String)var5.next();
                    builder.appendQueryParameter(key, (Boolean)supportedConversation.get(key) ? "true" : "false");
                }
            }

            context.startActivity(new Intent("android.intent.action.VIEW", builder.build()));
        }
    }

    public void startSubConversationList(Context context, Conversation.ConversationType conversationType) {
        if (context == null) {
            throw new IllegalArgumentException();
        } else if (RongContext.getInstance() == null) {
            throw new ExceptionInInitializerError("RongCloud SDK not init");
        } else {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("subconversationlist").appendQueryParameter("type", conversationType.getName()).build();
            context.startActivity(new Intent("android.intent.action.VIEW", uri));
        }
    }

    /** @deprecated */
    public static void setConversationBehaviorListener(RongIM.ConversationBehaviorListener listener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setConversationBehaviorListener(listener);
        }

    }

    public static void setConversationClickListener(RongIM.ConversationClickListener listener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setConversationClickListener(listener);
        }

    }

    public static void setConversationListBehaviorListener(RongIM.ConversationListBehaviorListener listener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setConversationListBehaviorListener(listener);
        }

    }

    public static void setPublicServiceBehaviorListener(RongIM.PublicServiceBehaviorListener listener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setPublicServiceBehaviorListener(listener);
        }

    }

    public void startPrivateChat(Context context, String targetUserId, String title) {
        if (context != null && !TextUtils.isEmpty(targetUserId)) {
            if (RongContext.getInstance() == null) {
                throw new ExceptionInInitializerError("RongCloud SDK not init");
            } else {
                Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.PRIVATE.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetUserId).appendQueryParameter("title", title).build();
                context.startActivity(new Intent("android.intent.action.VIEW", uri));
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startConversation(Context context, Conversation.ConversationType conversationType, String targetId, String title) {
        if (context != null && !TextUtils.isEmpty(targetId) && conversationType != null) {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().processName).buildUpon().appendPath("conversation").appendPath(conversationType.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetId).appendQueryParameter("title", title).build();
            context.startActivity(new Intent("android.intent.action.VIEW", uri));
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startConversation(Context context, Conversation.ConversationType conversationType, String targetId, String title, Bundle bundle) {
        if (context != null && !TextUtils.isEmpty(targetId) && conversationType != null) {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().processName).buildUpon().appendPath("conversation").appendPath(conversationType.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetId).appendQueryParameter("title", title).build();
            Intent intent = new Intent("android.intent.action.VIEW", uri);
            if (bundle != null) {
                intent.putExtras(bundle);
            }

            context.startActivity(intent);
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startConversation(Context context, Conversation.ConversationType conversationType, String targetId, String title, long fixedMsgSentTime) {
        if (context != null && !TextUtils.isEmpty(targetId) && conversationType != null) {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().processName).buildUpon().appendPath("conversation").appendPath(conversationType.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetId).appendQueryParameter("title", title).build();
            Intent intent = new Intent("android.intent.action.VIEW", uri);
            intent.putExtra("indexMessageTime", fixedMsgSentTime);
            context.startActivity(intent);
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void createDiscussionChat(final Context context, final List<String> targetUserIds, final String title) {
        if (context != null && targetUserIds != null && targetUserIds.size() != 0) {
            RongIMClient.getInstance().createDiscussion(title, targetUserIds, new RongIMClient.CreateDiscussionCallback() {
                public void onSuccess(String targetId) {
                    Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.DISCUSSION.getName().toLowerCase(Locale.US)).appendQueryParameter("targetIds", TextUtils.join(",", targetUserIds)).appendQueryParameter("delimiter", ",").appendQueryParameter("targetId", targetId).appendQueryParameter("title", title).build();
                    context.startActivity(new Intent("android.intent.action.VIEW", uri));
                }

                public void onError(RongIMClient.ErrorCode e) {
                    RLog.d(RongIM.TAG, "createDiscussionChat createDiscussion not success." + e);
                }
            });
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void createDiscussionChat(final Context context, final List<String> targetUserIds, final String title, final RongIMClient.CreateDiscussionCallback callback) {
        if (context != null && targetUserIds != null && targetUserIds.size() != 0) {
            RongIMClient.getInstance().createDiscussion(title, targetUserIds, new RongIMClient.CreateDiscussionCallback() {
                public void onSuccess(String targetId) {
                    Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.DISCUSSION.getName().toLowerCase(Locale.US)).appendQueryParameter("targetIds", TextUtils.join(",", targetUserIds)).appendQueryParameter("delimiter", ",").appendQueryParameter("targetId", targetId).appendQueryParameter("title", title).build();
                    context.startActivity(new Intent("android.intent.action.VIEW", uri));
                    if (callback != null) {
                        callback.onSuccess(targetId);
                    }

                }

                public void onError(RongIMClient.ErrorCode e) {
                    RLog.d(RongIM.TAG, "createDiscussionChat createDiscussion not success." + e);
                    if (callback != null) {
                        callback.onError(e);
                    }

                }
            });
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startDiscussionChat(Context context, String targetDiscussionId, String title) {
        if (context != null && !TextUtils.isEmpty(targetDiscussionId)) {
            Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.DISCUSSION.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetDiscussionId).appendQueryParameter("title", title).build();
            context.startActivity(new Intent("android.intent.action.VIEW", uri));
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startGroupChat(Context context, String targetGroupId, String title) {
        if (context != null && !TextUtils.isEmpty(targetGroupId)) {
            if (RongContext.getInstance() == null) {
                throw new ExceptionInInitializerError("RongCloud SDK not init");
            } else {
                Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.GROUP.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetGroupId).appendQueryParameter("title", title).build();
                context.startActivity(new Intent("android.intent.action.VIEW", uri));
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startChatRoomChat(Context context, String chatRoomId, boolean createIfNotExist) {
        if (context != null && !TextUtils.isEmpty(chatRoomId)) {
            if (RongContext.getInstance() == null) {
                throw new ExceptionInInitializerError("RongCloud SDK not init");
            } else {
                Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.CHATROOM.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", chatRoomId).build();
                Intent intent = new Intent("android.intent.action.VIEW", uri);
                intent.putExtra("createIfNotExist", createIfNotExist);
                context.startActivity(intent);
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void startCustomerServiceChat(Context context, String customerServiceId, String title, CSCustomServiceInfo customServiceInfo) {
        if (context != null && !TextUtils.isEmpty(customerServiceId)) {
            if (RongContext.getInstance() == null) {
                throw new ExceptionInInitializerError("RongCloud SDK not init");
            } else {
                Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon().appendPath("conversation").appendPath(Conversation.ConversationType.CUSTOMER_SERVICE.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", customerServiceId).appendQueryParameter("title", title).build();
                Intent intent = new Intent("android.intent.action.VIEW", uri);
                intent.putExtra("customServiceInfo", customServiceInfo);
                context.startActivity(intent);
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    public static void setUserInfoProvider(RongIM.UserInfoProvider userInfoProvider, boolean isCacheUserInfo) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setGetUserInfoProvider(userInfoProvider, isCacheUserInfo);
        }

    }

    public static void setPublicServiceProfileProvider(RongIM.PublicServiceProfileProvider publicServiceProfileProvider) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setPublicServiceProfileProvider(publicServiceProfileProvider);
        }

    }

    public static void setGroupUserInfoProvider(RongIM.GroupUserInfoProvider userInfoProvider, boolean isCacheUserInfo) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setGroupUserInfoProvider(userInfoProvider, isCacheUserInfo);
        }

    }

    public static void setGroupInfoProvider(RongIM.GroupInfoProvider groupInfoProvider, boolean isCacheGroupInfo) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setGetGroupInfoProvider(groupInfoProvider, isCacheGroupInfo);
        }

    }

    public void refreshDiscussionCache(Discussion discussion) {
        if (discussion != null) {
            RongUserInfoManager.getInstance().setDiscussionInfo(discussion);
        }
    }

    public void refreshUserInfoCache(UserInfo userInfo) {
        if (userInfo != null) {
            RongUserInfoManager.getInstance().setUserInfo(userInfo);
            UserInfo currentUserInfo = RongContext.getInstance().getCurrentUserInfo();
            if (currentUserInfo != null && currentUserInfo.getUserId().equals(userInfo.getUserId())) {
                RongContext.getInstance().setCurrentUserInfo(userInfo);
            }

            Uri portrait = userInfo.getPortraitUri();
            RongIMClient.getInstance().updateConversationInfo(Conversation.ConversationType.PRIVATE, userInfo.getUserId(), userInfo.getName(), portrait != null ? portrait.toString() : "", (RongIMClient.ResultCallback)null);
        }
    }

    public void refreshGroupUserInfoCache(GroupUserInfo groupUserInfo) {
        if (groupUserInfo != null) {
            RongUserInfoManager.getInstance().setGroupUserInfo(groupUserInfo);
        }
    }

    public void refreshGroupInfoCache(Group group) {
        if (group != null) {
            RongUserInfoManager.getInstance().setGroupInfo(group);
            Uri groupPortrait = group.getPortraitUri();
            RongIMClient.getInstance().updateConversationInfo(Conversation.ConversationType.GROUP, group.getId(), group.getName(), groupPortrait != null ? groupPortrait.toString() : "", (RongIMClient.ResultCallback)null);
        }
    }

    public void refreshPublicServiceProfile(PublicServiceProfile publicServiceProfile) {
        if (publicServiceProfile != null) {
            RongUserInfoManager.getInstance().setPublicServiceProfile(publicServiceProfile);
        }
    }

    public void setSendMessageListener(RongIM.OnSendMessageListener listener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setOnSendMessageListener(listener);
        }

    }

    public void setMessageAttachedUserInfo(boolean state) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setUserInfoAttachedState(state);
        }

    }

    /** @deprecated */
    @Deprecated
    public void setOnReceiveUnreadCountChangedListener(final RongIM.OnReceiveUnreadCountChangedListener listener, Conversation.ConversationType... conversationTypes) {
        if (listener != null && conversationTypes != null && conversationTypes.length != 0) {
            UnReadMessageManager.getInstance().addObserver(conversationTypes, new IUnReadMessageObserver() {
                public void onCountChanged(int count) {
                    listener.onMessageIncreased(count);
                }
            });
        } else {
            RLog.w(TAG, "setOnReceiveUnreadCountChangedListener Illegal argument");
        }
    }

    public void addUnReadMessageCountChangedObserver(IUnReadMessageObserver observer, Conversation.ConversationType... conversationTypes) {
        if (observer != null && conversationTypes != null && conversationTypes.length != 0) {
            UnReadMessageManager.getInstance().addObserver(conversationTypes, observer);
        } else {
            RLog.w(TAG, "addOnReceiveUnreadCountChangedListener Illegal argument");
            throw new IllegalArgumentException("observer must not be null and must include at least one conversationType");
        }
    }

    public void removeUnReadMessageCountChangedObserver(IUnReadMessageObserver observer) {
        if (observer == null) {
            RLog.w(TAG, "removeOnReceiveUnreadCountChangedListener Illegal argument");
        } else {
            UnReadMessageManager.getInstance().removeObserver(observer);
        }
    }

    public void startPublicServiceProfile(Context context, Conversation.ConversationType conversationType, String targetId) {
        if (context != null && conversationType != null && !TextUtils.isEmpty(targetId)) {
            if (RongContext.getInstance() == null) {
                throw new ExceptionInInitializerError("RongCloud SDK not init");
            } else {
                Uri uri = Uri.parse("rong://" + context.getApplicationInfo().processName).buildUpon().appendPath("publicServiceProfile").appendPath(conversationType.getName().toLowerCase(Locale.US)).appendQueryParameter("targetId", targetId).build();
                Intent intent = new Intent("android.intent.action.VIEW", uri);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    public void registerConversationTemplate(IContainerItemProvider.ConversationProvider provider) {
        if (RongContext.getInstance() != null) {
            if (provider == null) {
                throw new IllegalArgumentException();
            }

            RongContext.getInstance().registerConversationTemplate(provider);
        }

    }

    public void enableNewComingMessageIcon(boolean state) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().showNewMessageIcon(state);
        }

    }

    public void enableUnreadMessageIcon(boolean state) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().showUnreadMessageIcon(state);
        }

    }

    public void setMaxVoiceDurationg(int sec) {
        AudioRecordManager.getInstance().setMaxVoiceDuration(sec);
    }

    public RongIMClient.ConnectionStatusListener.ConnectionStatus getCurrentConnectionStatus() {
        return RongIMClient.getInstance().getCurrentConnectionStatus();
    }

    public void getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback) {
        RongIMClient.getInstance().getConversationList(callback);
    }

    /** @deprecated */
    @Deprecated
    public List<Conversation> getConversationList() {
        return RongIMClient.getInstance().getConversationList();
    }

    public void getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Conversation.ConversationType... types) {
        RongIMClient.getInstance().getConversationList(callback, types);
    }

    /** @deprecated */
    @Deprecated
    public List<Conversation> getConversationList(Conversation.ConversationType... types) {
        return RongIMClient.getInstance().getConversationList(types);
    }

    public void getConversation(Conversation.ConversationType type, String targetId, RongIMClient.ResultCallback<Conversation> callback) {
        RongIMClient.getInstance().getConversation(type, targetId, callback);
    }

    /** @deprecated */
    @Deprecated
    public Conversation getConversation(Conversation.ConversationType type, String targetId) {
        return RongIMClient.getInstance().getConversation(type, targetId);
    }

    public void removeConversation(final Conversation.ConversationType type, final String targetId, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().removeConversation(type, targetId, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (callback != null) {
                    callback.onSuccess(bool);
                }

                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.ConversationRemoveEvent(type, targetId));
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public boolean removeConversation(Conversation.ConversationType type, String targetId) {
        boolean result = RongIMClient.getInstance().removeConversation(type, targetId);
        if (result) {
            RongContext.getInstance().getEventBus().post(new Event.ConversationRemoveEvent(type, targetId));
        }

        return result;
    }

    public void setConversationToTop(final Conversation.ConversationType type, final String id, final boolean isTop, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().setConversationToTop(type, id, isTop, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (callback != null) {
                    callback.onSuccess(bool);
                }

                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.ConversationTopEvent(type, id, isTop));
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public boolean setConversationToTop(Conversation.ConversationType conversationType, String targetId, boolean isTop) {
        boolean result = RongIMClient.getInstance().setConversationToTop(conversationType, targetId, isTop);
        if (result) {
            RongContext.getInstance().getEventBus().post(new Event.ConversationTopEvent(conversationType, targetId, isTop));
        }

        return result;
    }

    public void getTotalUnreadCount(final RongIMClient.ResultCallback<Integer> callback) {
        RongIMClient.getInstance().getTotalUnreadCount(new RongIMClient.ResultCallback<Integer>() {
            public void onSuccess(Integer integer) {
                if (callback != null) {
                    callback.onSuccess(integer);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public int getTotalUnreadCount() {
        return RongIMClient.getInstance().getTotalUnreadCount();
    }

    public void getUnreadCount(Conversation.ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Integer> callback) {
        RongIMClient.getInstance().getUnreadCount(conversationType, targetId, callback);
    }

    /** @deprecated */
    @Deprecated
    public int getUnreadCount(Conversation.ConversationType conversationType, String targetId) {
        return RongIMClient.getInstance().getUnreadCount(conversationType, targetId);
    }

    public void getUnreadCount(RongIMClient.ResultCallback<Integer> callback, Conversation.ConversationType... conversationTypes) {
        RongIMClient.getInstance().getUnreadCount(callback, conversationTypes);
    }

    /** @deprecated */
    @Deprecated
    public int getUnreadCount(Conversation.ConversationType... conversationTypes) {
        return RongIMClient.getInstance().getUnreadCount(conversationTypes);
    }

    public void getUnreadCount(Conversation.ConversationType[] conversationTypes, RongIMClient.ResultCallback<Integer> callback) {
        RongIMClient.getInstance().getUnreadCount(conversationTypes, callback);
    }

    /** @deprecated */
    @Deprecated
    public List<Message> getLatestMessages(Conversation.ConversationType conversationType, String targetId, int count) {
        return RongIMClient.getInstance().getLatestMessages(conversationType, targetId, count);
    }

    public void getLatestMessages(Conversation.ConversationType conversationType, String targetId, int count, RongIMClient.ResultCallback<List<Message>> callback) {
        RongIMClient.getInstance().getLatestMessages(conversationType, targetId, count, callback);
    }

    /** @deprecated */
    @Deprecated
    public List<Message> getHistoryMessages(Conversation.ConversationType conversationType, String targetId, int oldestMessageId, int count) {
        return RongIMClient.getInstance().getHistoryMessages(conversationType, targetId, oldestMessageId, count);
    }

    /** @deprecated */
    @Deprecated
    public List<Message> getHistoryMessages(Conversation.ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count) {
        return RongIMClient.getInstance().getHistoryMessages(conversationType, targetId, objectName, oldestMessageId, count);
    }

    public void getHistoryMessages(Conversation.ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback) {
        RongIMClient.getInstance().getHistoryMessages(conversationType, targetId, objectName, oldestMessageId, count, callback);
    }

    public void getHistoryMessages(Conversation.ConversationType conversationType, String targetId, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback) {
        RongIMClient.getInstance().getHistoryMessages(conversationType, targetId, oldestMessageId, count, callback);
    }

    public void getRemoteHistoryMessages(Conversation.ConversationType conversationType, String targetId, long dataTime, int count, RongIMClient.ResultCallback<List<Message>> callback) {
        RongIMClient.getInstance().getRemoteHistoryMessages(conversationType, targetId, dataTime, count, callback);
    }

    /** @deprecated */
    @Deprecated
    public boolean deleteMessages(int[] messageIds) {
        Boolean bool = RongIMClient.getInstance().deleteMessages(messageIds);
        if (bool) {
            RongContext.getInstance().getEventBus().post(new Event.MessageDeleteEvent(messageIds));
        }

        return bool;
    }

    public void deleteMessages(final int[] messageIds, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().deleteMessages(messageIds, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.MessageDeleteEvent(messageIds));
                }

                if (callback != null) {
                    callback.onSuccess(bool);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    public void deleteMessages(final Conversation.ConversationType conversationType, final String targetId, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().deleteMessages(conversationType, targetId, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.MessagesClearEvent(conversationType, targetId));
                }

                if (callback != null) {
                    callback.onSuccess(bool);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public boolean clearMessages(Conversation.ConversationType conversationType, String targetId) {
        boolean bool = RongIMClient.getInstance().clearMessages(conversationType, targetId);
        if (bool) {
            RongContext.getInstance().getEventBus().post(new Event.MessagesClearEvent(conversationType, targetId));
        }

        return bool;
    }

    public void clearMessages(final Conversation.ConversationType conversationType, final String targetId, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().clearMessages(conversationType, targetId, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.MessagesClearEvent(conversationType, targetId));
                }

                if (callback != null) {
                    callback.onSuccess(bool);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public boolean clearMessagesUnreadStatus(Conversation.ConversationType conversationType, String targetId) {
        boolean result = RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId);
        if (result) {
            RongContext.getInstance().getEventBus().post(new Event.ConversationUnreadEvent(conversationType, targetId));
        }

        return result;
    }

    public void clearMessagesUnreadStatus(final Conversation.ConversationType conversationType, final String targetId, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (callback != null) {
                    callback.onSuccess(bool);
                }

                RongContext.getInstance().getEventBus().post(new Event.ConversationUnreadEvent(conversationType, targetId));
            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public boolean setMessageExtra(int messageId, String value) {
        return RongIMClient.getInstance().setMessageExtra(messageId, value);
    }

    public void setMessageExtra(int messageId, String value, RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().setMessageExtra(messageId, value, callback);
    }

    /** @deprecated */
    @Deprecated
    public boolean setMessageReceivedStatus(int messageId, Message.ReceivedStatus receivedStatus) {
        return RongIMClient.getInstance().setMessageReceivedStatus(messageId, receivedStatus);
    }

    public void setMessageReceivedStatus(int messageId, Message.ReceivedStatus receivedStatus, RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().setMessageReceivedStatus(messageId, receivedStatus, callback);
    }

    /** @deprecated */
    @Deprecated
    public boolean setMessageSentStatus(int messageId, Message.SentStatus sentStatus) {
        boolean result = RongIMClient.getInstance().setMessageSentStatus(messageId, sentStatus);
        if (result) {
            RongContext.getInstance().getEventBus().post(new Event.MessageSentStatusEvent(messageId, sentStatus));
        }

        return result;
    }

    public void setMessageSentStatus(final int messageId, final Message.SentStatus sentStatus, final RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().setMessageSentStatus(messageId, sentStatus, new RongIMClient.ResultCallback<Boolean>() {
            public void onSuccess(Boolean bool) {
                if (callback != null) {
                    callback.onSuccess(bool);
                }

                if (bool) {
                    RongContext.getInstance().getEventBus().post(new Event.MessageSentStatusEvent(messageId, sentStatus));
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public String getTextMessageDraft(Conversation.ConversationType conversationType, String targetId) {
        return RongIMClient.getInstance().getTextMessageDraft(conversationType, targetId);
    }

    /** @deprecated */
    @Deprecated
    public boolean saveTextMessageDraft(Conversation.ConversationType conversationType, String targetId, String content) {
        return RongIMClient.getInstance().saveTextMessageDraft(conversationType, targetId, content);
    }

    /** @deprecated */
    @Deprecated
    public boolean clearTextMessageDraft(Conversation.ConversationType conversationType, String targetId) {
        return RongIMClient.getInstance().clearTextMessageDraft(conversationType, targetId);
    }

    public void getTextMessageDraft(Conversation.ConversationType conversationType, String targetId, RongIMClient.ResultCallback<String> callback) {
        RongIMClient.getInstance().getTextMessageDraft(conversationType, targetId, callback);
    }

    public void saveTextMessageDraft(Conversation.ConversationType conversationType, String targetId, String content, RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().saveTextMessageDraft(conversationType, targetId, content, callback);
    }

    public void clearTextMessageDraft(Conversation.ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback) {
        RongIMClient.getInstance().clearTextMessageDraft(conversationType, targetId, callback);
    }

    public void getDiscussion(String discussionId, RongIMClient.ResultCallback<Discussion> callback) {
        RongIMClient.getInstance().getDiscussion(discussionId, callback);
    }

    public void setDiscussionName(final String discussionId, final String name, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().setDiscussionName(discussionId, name, new RongIMClient.OperationCallback() {
            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }

            public void onSuccess() {
                if (callback != null) {
                    RongUserInfoManager.getInstance().setDiscussionInfo(new Discussion(discussionId, name));
                    callback.onSuccess();
                }

            }
        });
    }

    public void createDiscussion(final String name, final List<String> userIdList, final RongIMClient.CreateDiscussionCallback callback) {
        RongIMClient.getInstance().createDiscussion(name, userIdList, new RongIMClient.CreateDiscussionCallback() {
            public void onSuccess(String discussionId) {
                RongContext.getInstance().getEventBus().post(new Event.CreateDiscussionEvent(discussionId, name, userIdList));
                if (callback != null) {
                    callback.onSuccess(discussionId);
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void addMemberToDiscussion(final String discussionId, final List<String> userIdList, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().addMemberToDiscussion(discussionId, userIdList, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.AddMemberToDiscussionEvent(discussionId, userIdList));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void removeMemberFromDiscussion(final String discussionId, final String userId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().removeMemberFromDiscussion(discussionId, userId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.RemoveMemberFromDiscussionEvent(discussionId, userId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void quitDiscussion(final String discussionId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().quitDiscussion(discussionId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.QuitDiscussionEvent(discussionId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    /** @deprecated */
    public void insertMessage(Conversation.ConversationType type, String targetId, String senderUserId, MessageContent content, long sentTime, final RongIMClient.ResultCallback<Message> callback) {
        MessageTag tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
        if (tag != null && (tag.flag() & 1) == 1) {
            RongIMClient.getInstance().insertMessage(type, targetId, senderUserId, content, sentTime, new RongIMClient.ResultCallback<Message>() {
                public void onSuccess(Message message) {
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                    RongContext.getInstance().getEventBus().post(message);
                }

                public void onError(RongIMClient.ErrorCode e) {
                    if (callback != null) {
                        callback.onError(e);
                    }

                    RongContext.getInstance().getEventBus().post(e);
                }
            });
        } else {
            RLog.e(TAG, "insertMessage Message is missing MessageTag.ISPERSISTED");
        }

    }

    /** @deprecated */
    public void insertMessage(Conversation.ConversationType conversationType, String targetId, String senderUserId, MessageContent content, RongIMClient.ResultCallback<Message> callback) {
        this.insertMessage(conversationType, targetId, senderUserId, content, System.currentTimeMillis(), callback);
    }

    /** @deprecated */
    @Deprecated
    public Message insertMessage(Conversation.ConversationType type, String targetId, String senderUserId, MessageContent content) {
        MessageTag tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
        Message message;
        if (tag != null && (tag.flag() & 1) == 1) {
            message = RongIMClient.getInstance().insertMessage(type, targetId, senderUserId, content);
        } else {
            message = Message.obtain(targetId, type, content);
            RLog.e(TAG, "insertMessage Message is missing MessageTag.ISPERSISTED");
        }

        RongContext.getInstance().getEventBus().post(message);
        return message;
    }

    public void insertIncomingMessage(Conversation.ConversationType type, String targetId, String senderUserId, Message.ReceivedStatus receivedStatus, MessageContent content, RongIMClient.ResultCallback<Message> callback) {
        this.insertIncomingMessage(type, targetId, senderUserId, receivedStatus, content, System.currentTimeMillis(), callback);
    }

    public void insertIncomingMessage(Conversation.ConversationType type, String targetId, String senderUserId, Message.ReceivedStatus receivedStatus, MessageContent content, long sentTime, final RongIMClient.ResultCallback<Message> callback) {
        MessageTag tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
        if (tag != null && (tag.flag() & 1) == 1) {
            RongIMClient.getInstance().insertIncomingMessage(type, targetId, senderUserId, receivedStatus, content, sentTime, new RongIMClient.ResultCallback<Message>() {
                public void onSuccess(Message message) {
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                    RongContext.getInstance().getEventBus().post(message);
                }

                public void onError(RongIMClient.ErrorCode e) {
                    if (callback != null) {
                        callback.onError(e);
                    }

                    RongContext.getInstance().getEventBus().post(e);
                }
            });
        } else {
            RLog.e(TAG, "insertMessage Message is missing MessageTag.ISPERSISTED");
        }

    }

    public void insertOutgoingMessage(Conversation.ConversationType type, String targetId, Message.SentStatus sentStatus, MessageContent content, RongIMClient.ResultCallback<Message> callback) {
        this.insertOutgoingMessage(type, targetId, sentStatus, content, System.currentTimeMillis(), callback);
    }

    public void insertOutgoingMessage(Conversation.ConversationType type, String targetId, Message.SentStatus sentStatus, MessageContent content, long sentTime, final RongIMClient.ResultCallback<Message> callback) {
        MessageTag tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
        if (tag != null && (tag.flag() & 1) == 1) {
            RongIMClient.getInstance().insertOutgoingMessage(type, targetId, sentStatus, content, sentTime, new RongIMClient.ResultCallback<Message>() {
                public void onSuccess(Message message) {
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                    RongContext.getInstance().getEventBus().post(message);
                }

                public void onError(RongIMClient.ErrorCode e) {
                    if (callback != null) {
                        callback.onError(e);
                    }

                    RongContext.getInstance().getEventBus().post(e);
                }
            });
        } else {
            RLog.e(TAG, "insertMessage Message is missing MessageTag.ISPERSISTED");
        }

    }

    /** @deprecated */
    @Deprecated
    public Message sendMessage(Conversation.ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, final RongIMClient.SendMessageCallback callback) {
        final RongIMClient.ResultCallback.Result<Message> result = new RongIMClient.ResultCallback.Result();
        Message messageTemp = Message.obtain(targetId, type, content);
        Message temp = this.filterSendMessage(messageTemp);
        if (temp == null) {
            return null;
        } else {
            if (temp != messageTemp) {
                messageTemp = temp;
            }

            content = messageTemp.getContent();
            content = this.setMessageAttachedUserInfo(content);
            Message message = RongIMClient.getInstance().sendMessage(type, targetId, content, pushContent, pushData, new RongIMClient.SendMessageCallback() {
                public void onSuccess(Integer messageId) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.SENT);
                        long tt = RongIMClient.getInstance().getSendTimeByMessageId(messageId);
                        if (tt != 0L) {
                            ((Message)result.t).setSentTime(tt);
                        }

                        RongIM.this.filterSentMessage((Message)result.t, (RongIMClient.ErrorCode)null);
                        if (callback != null) {
                            callback.onSuccess(messageId);
                        }

                    }
                }

                public void onError(Integer messageId, RongIMClient.ErrorCode errorCode) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.FAILED);
                        RongIM.this.filterSentMessage((Message)result.t, errorCode);
                        if (callback != null) {
                            callback.onError(messageId, errorCode);
                        }

                    }
                }
            });
            MessageTag tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
            if (tag != null && (tag.flag() & 1) == 1) {
                RongContext.getInstance().getEventBus().post(message);
            }

            result.t = message;
            return message;
        }
    }

    /** @deprecated */
    public void sendMessage(Conversation.ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, final RongIMClient.SendMessageCallback callback, final RongIMClient.ResultCallback<Message> resultCallback) {
        final RongIMClient.ResultCallback.Result<Message> result = new RongIMClient.ResultCallback.Result();
        Message message = Message.obtain(targetId, type, content);
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            content = message.getContent();
            content = this.setMessageAttachedUserInfo(content);
            RongIMClient.getInstance().sendMessage(type, targetId, content, pushContent, pushData, new RongIMClient.SendMessageCallback() {
                public void onSuccess(Integer messageId) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.SENT);
                        long tt = RongIMClient.getInstance().getSendTimeByMessageId(messageId);
                        if (tt != 0L) {
                            ((Message)result.t).setSentTime(tt);
                        }

                        RongIM.this.filterSentMessage((Message)result.t, (RongIMClient.ErrorCode)null);
                        if (callback != null) {
                            callback.onSuccess(messageId);
                        }

                    }
                }

                public void onError(Integer messageId, RongIMClient.ErrorCode errorCode) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.FAILED);
                        RongIM.this.filterSentMessage((Message)result.t, errorCode);
                        if (callback != null) {
                            callback.onError(messageId, errorCode);
                        }

                    }
                }
            }, new RongIMClient.ResultCallback<Message>() {
                public void onSuccess(Message message) {
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    result.t = message;
                    if (resultCallback != null) {
                        resultCallback.onSuccess(message);
                    }

                }

                public void onError(RongIMClient.ErrorCode e) {
                    RongContext.getInstance().getEventBus().post(e);
                    if (resultCallback != null) {
                        resultCallback.onError(e);
                    }

                }
            });
        }
    }

    /** @deprecated */
    public void sendMessage(Message message, String pushContent, String pushData, final RongIMClient.SendMessageCallback callback, final RongIMClient.ResultCallback<Message> resultCallback) {
        final RongIMClient.ResultCallback.Result<Message> result = new RongIMClient.ResultCallback.Result();
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            message.setContent(this.setMessageAttachedUserInfo(message.getContent()));
            RongIMClient.getInstance().sendMessage(message, pushContent, pushData, new RongIMClient.SendMessageCallback() {
                public void onSuccess(Integer messageId) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.SENT);
                        long tt = RongIMClient.getInstance().getSendTimeByMessageId(messageId);
                        if (tt != 0L) {
                            ((Message)result.t).setSentTime(tt);
                        }

                        RongIM.this.filterSentMessage((Message)result.t, (RongIMClient.ErrorCode)null);
                        if (callback != null) {
                            callback.onSuccess(messageId);
                        }

                    }
                }

                public void onError(Integer messageId, RongIMClient.ErrorCode errorCode) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.FAILED);
                        RongIM.this.filterSentMessage((Message)result.t, errorCode);
                        if (callback != null) {
                            callback.onError(messageId, errorCode);
                        }

                    }
                }
            }, new RongIMClient.ResultCallback<Message>() {
                public void onSuccess(Message message) {
                    result.t = message;
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    if (resultCallback != null) {
                        resultCallback.onSuccess(message);
                    }

                }

                public void onError(RongIMClient.ErrorCode e) {
                    RongContext.getInstance().getEventBus().post(e);
                    if (resultCallback != null) {
                        resultCallback.onError(e);
                    }

                }
            });
        }
    }

    /** @deprecated */
    @Deprecated
    public Message sendMessage(Message message, String pushContent, String pushData, final RongIMClient.SendMessageCallback callback) {
        final RongIMClient.ResultCallback.Result<Message> result = new RongIMClient.ResultCallback.Result();
        Message temp = this.filterSendMessage(message);
        if (temp == null) {
            return null;
        } else {
            if (temp != message) {
                message = temp;
            }

            message.setContent(this.setMessageAttachedUserInfo(message.getContent()));
            Message msg = RongIMClient.getInstance().sendMessage(message, pushContent, pushData, new RongIMClient.SendMessageCallback() {
                public void onSuccess(Integer messageId) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.SENT);
                        long tt = RongIMClient.getInstance().getSendTimeByMessageId(messageId);
                        if (tt != 0L) {
                            ((Message)result.t).setSentTime(tt);
                        }

                        RongIM.this.filterSentMessage((Message)result.t, (RongIMClient.ErrorCode)null);
                        if (callback != null) {
                            callback.onSuccess(messageId);
                        }

                    }
                }

                public void onError(Integer messageId, RongIMClient.ErrorCode errorCode) {
                    if (result.t != null) {
                        ((Message)result.t).setSentStatus(Message.SentStatus.FAILED);
                        RongIM.this.filterSentMessage((Message)result.t, errorCode);
                        if (callback != null) {
                            callback.onError(messageId, errorCode);
                        }

                    }
                }
            });
            MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
            if (tag != null && (tag.flag() & 1) == 1) {
                EventBus.getDefault().post(msg);
            }

            result.t = msg;
            return msg;
        }
    }

    public void sendMessage(Message message, String pushContent, String pushData, final IRongCallback.ISendMessageCallback callback) {
        Message filterMsg = this.filterSendMessage(message);
        if (filterMsg == null) {
            RLog.w(TAG, "sendMessage: 因在 onSend 中消息被过滤为 null，取消发送。");
        } else {
            if (filterMsg != message) {
                message = filterMsg;
            }

            message.setContent(this.setMessageAttachedUserInfo(message.getContent()));
            RongIMClient.getInstance().sendMessage(message, pushContent, pushData, new IRongCallback.ISendMessageCallback() {
                public void onAttached(Message message) {
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    if (callback != null) {
                        callback.onAttached(message);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }
            });
        }
    }

    public void sendLocationMessage(Message message, String pushContent, String pushData, final IRongCallback.ISendMessageCallback sendMessageCallback) {
        Message filterMsg = this.filterSendMessage(message);
        if (filterMsg == null) {
            RLog.w(TAG, "sendLocationMessage: 因在 onSend 中消息被过滤为 null，取消发送。");
        } else {
            if (filterMsg != message) {
                message = filterMsg;
            }

            message.setContent(this.setMessageAttachedUserInfo(message.getContent()));
            RongIMClient.getInstance().sendLocationMessage(message, pushContent, pushData, new IRongCallback.ISendMessageCallback() {
                public void onAttached(Message message) {
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    if (sendMessageCallback != null) {
                        sendMessageCallback.onAttached(message);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (sendMessageCallback != null) {
                        sendMessageCallback.onSuccess(message);
                    }

                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (sendMessageCallback != null) {
                        sendMessageCallback.onError(message, errorCode);
                    }

                }
            });
        }
    }

    public void sendImageMessage(Conversation.ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, final RongIMClient.SendImageMessageCallback callback) {
        Message message = Message.obtain(targetId, type, content);
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            content = message.getContent();
            content = this.setMessageAttachedUserInfo(content);
            final RongIMClient.ResultCallback.Result<Event.OnReceiveMessageProgressEvent> result = new RongIMClient.ResultCallback.Result();
            result.t = new Event.OnReceiveMessageProgressEvent();
            RongIMClient.SendImageMessageCallback sendMessageCallback = new RongIMClient.SendImageMessageCallback() {
                public void onAttached(Message message) {
                    RongContext.getInstance().getEventBus().post(message);
                    if (callback != null) {
                        callback.onAttached(message);
                    }

                }

                public void onProgress(Message message, int progress) {
                    if (result.t != null) {
                        ((Event.OnReceiveMessageProgressEvent)result.t).setMessage(message);
                        ((Event.OnReceiveMessageProgressEvent)result.t).setProgress(progress);
                        RongContext.getInstance().getEventBus().post(result.t);
                        if (callback != null) {
                            callback.onProgress(message, progress);
                        }

                    }
                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }
            };
            RongIMClient.getInstance().sendImageMessage(type, targetId, content, pushContent, pushData, sendMessageCallback);
        }
    }

    public void sendImageMessage(Message message, String pushContent, String pushData, boolean filter, final RongIMClient.SendImageMessageCallback callback) {
        if (filter) {
            Message temp = this.filterSendMessage(message);
            if (temp == null) {
                return;
            }

            if (temp != message) {
                message = temp;
            }
        }

        this.setMessageAttachedUserInfo(message.getContent());
        final RongIMClient.ResultCallback.Result<Event.OnReceiveMessageProgressEvent> result = new RongIMClient.ResultCallback.Result();
        result.t = new Event.OnReceiveMessageProgressEvent();
        RongIMClient.SendImageMessageCallback sendMessageCallback = new RongIMClient.SendImageMessageCallback() {
            public void onAttached(Message message) {
                RongContext.getInstance().getEventBus().post(message);
                if (callback != null) {
                    callback.onAttached(message);
                }

            }

            public void onProgress(Message message, int progress) {
                if (result.t != null) {
                    ((Event.OnReceiveMessageProgressEvent)result.t).setMessage(message);
                    ((Event.OnReceiveMessageProgressEvent)result.t).setProgress(progress);
                    RongContext.getInstance().getEventBus().post(result.t);
                    if (callback != null) {
                        callback.onProgress(message, progress);
                    }

                }
            }

            public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                RongIM.this.filterSentMessage(message, errorCode);
                if (callback != null) {
                    callback.onError(message, errorCode);
                }

            }

            public void onSuccess(Message message) {
                RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                if (callback != null) {
                    callback.onSuccess(message);
                }

            }
        };
        RongIMClient.getInstance().sendImageMessage(message, pushContent, pushData, sendMessageCallback);
    }

    public void sendImageMessage(Message message, String pushContent, String pushData, RongIMClient.SendImageMessageCallback callback) {
        this.sendImageMessage(message, pushContent, pushData, true, callback);
    }

    public void sendImageMessage(Message message, String pushContent, String pushData, final RongIMClient.SendImageMessageWithUploadListenerCallback callback) {
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            final RongIMClient.ResultCallback.Result<Event.OnReceiveMessageProgressEvent> result = new RongIMClient.ResultCallback.Result();
            result.t = new Event.OnReceiveMessageProgressEvent();
            RongIMClient.SendImageMessageWithUploadListenerCallback sendMessageCallback = new RongIMClient.SendImageMessageWithUploadListenerCallback() {
                public void onAttached(Message message, RongIMClient.UploadImageStatusListener listener) {
                    RongContext.getInstance().getEventBus().post(message);
                    if (callback != null) {
                        callback.onAttached(message, listener);
                    }

                }

                public void onProgress(Message message, int progress) {
                    if (result.t != null) {
                        ((Event.OnReceiveMessageProgressEvent)result.t).setMessage(message);
                        ((Event.OnReceiveMessageProgressEvent)result.t).setProgress(progress);
                        RongContext.getInstance().getEventBus().post(result.t);
                        if (callback != null) {
                            callback.onProgress(message, progress);
                        }

                    }
                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }
            };
            RongIMClient.getInstance().sendImageMessage(message, pushContent, pushData, sendMessageCallback);
        }
    }

    public void downloadMedia(Conversation.ConversationType conversationType, String targetId, RongIMClient.MediaType mediaType, String imageUrl, RongIMClient.DownloadMediaCallback callback) {
        RongIMClient.getInstance().downloadMedia(conversationType, targetId, mediaType, imageUrl, callback);
    }

    public void downloadMediaMessage(Message message, final IRongCallback.IDownloadMediaMessageCallback callback) {
        RongIMClient.getInstance().downloadMediaMessage(message, new IRongCallback.IDownloadMediaMessageCallback() {
            public void onSuccess(Message message) {
                EventBus.getDefault().post(new Event.FileMessageEvent(message, 100, 100, (RongIMClient.ErrorCode)null));
                if (callback != null) {
                    callback.onSuccess(message);
                }

            }

            public void onProgress(Message message, int progress) {
                EventBus.getDefault().post(new Event.FileMessageEvent(message, progress, 101, (RongIMClient.ErrorCode)null));
                if (callback != null) {
                    callback.onProgress(message, progress);
                }

            }

            public void onError(Message message, RongIMClient.ErrorCode code) {
                EventBus.getDefault().post(new Event.FileMessageEvent(message, 0, 103, code));
                if (callback != null) {
                    callback.onError(message, code);
                }

            }

            public void onCanceled(Message message) {
                EventBus.getDefault().post(new Event.FileMessageEvent(message, 0, 102, (RongIMClient.ErrorCode)null));
                if (callback != null) {
                    callback.onCanceled(message);
                }

            }
        });
    }

    public void downloadMedia(String imageUrl, final RongIMClient.DownloadMediaCallback callback) {
        ImageLoader.getInstance().loadImage(imageUrl, (ImageSize)null, (DisplayImageOptions)null, new ImageLoadingListener() {
            public void onLoadingStarted(String imageUri, View view) {
            }

            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                if (callback != null) {
                    callback.onError(ErrorCode.RC_NET_UNAVAILABLE);
                }

            }

            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                if (callback != null) {
                    callback.onSuccess(imageUri);
                }

            }

            public void onLoadingCancelled(String imageUri, View view) {
            }
        }, new ImageLoadingProgressListener() {
            public void onProgressUpdate(String imageUri, View view, int current, int total) {
                if (callback != null) {
                    callback.onProgress(current * 100 / total);
                }

            }
        });
    }

    public void getConversationNotificationStatus(final Conversation.ConversationType conversationType, final String targetId, final RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus> callback) {
        RongIMClient.getInstance().getConversationNotificationStatus(conversationType, targetId, new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {
            public void onSuccess(Conversation.ConversationNotificationStatus status) {
                RongContext.getInstance().setConversationNotifyStatusToCache(ConversationKey.obtain(targetId, conversationType), status);
                if (callback != null) {
                    callback.onSuccess(status);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        });
    }

    public void setConversationNotificationStatus(final Conversation.ConversationType conversationType, final String targetId, final Conversation.ConversationNotificationStatus notificationStatus, final RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus> callback) {
        RongIMClient.getInstance().setConversationNotificationStatus(conversationType, targetId, notificationStatus, new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {
            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }

            public void onSuccess(Conversation.ConversationNotificationStatus status) {
                RongContext.getInstance().setConversationNotifyStatusToCache(ConversationKey.obtain(targetId, conversationType), status);
                RongContext.getInstance().getEventBus().post(new Event.ConversationNotificationEvent(targetId, conversationType, notificationStatus));
                if (callback != null) {
                    callback.onSuccess(status);
                }

            }
        });
    }

    public void setDiscussionInviteStatus(final String discussionId, final RongIMClient.DiscussionInviteStatus status, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().setDiscussionInviteStatus(discussionId, status, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.DiscussionInviteStatusEvent(discussionId, status));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public void syncGroup(final List<Group> groups, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().syncGroup(groups, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.SyncGroupEvent(groups));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public void joinGroup(final String groupId, final String groupName, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().joinGroup(groupId, groupName, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.JoinGroupEvent(groupId, groupName));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public void quitGroup(final String groupId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().quitGroup(groupId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.QuitGroupEvent(groupId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public String getCurrentUserId() {
        return RongIMClient.getInstance().getCurrentUserId();
    }

    public long getDeltaTime() {
        return RongIMClient.getInstance().getDeltaTime();
    }

    public void joinChatRoom(final String chatroomId, final int defMessageCount, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().joinChatRoom(chatroomId, defMessageCount, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.JoinChatRoomEvent(chatroomId, defMessageCount));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void joinExistChatRoom(final String chatroomId, final int defMessageCount, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().joinExistChatRoom(chatroomId, defMessageCount, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.JoinChatRoomEvent(chatroomId, defMessageCount));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void quitChatRoom(final String chatroomId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().quitChatRoom(chatroomId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.QuitChatRoomEvent(chatroomId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void clearConversations(final RongIMClient.ResultCallback callback, final Conversation.ConversationType... conversationTypes) {
        RongIMClient.getInstance().clearConversations(new RongIMClient.ResultCallback() {
            public void onSuccess(Object o) {
                RongContext.getInstance().getEventBus().post(Event.ClearConversationEvent.obtain(conversationTypes));
                if (callback != null) {
                    callback.onSuccess(o);
                }

            }

            public void onError(RongIMClient.ErrorCode e) {
                if (callback != null) {
                    callback.onError(e);
                }

            }
        }, conversationTypes);
    }

    /** @deprecated */
    @Deprecated
    public boolean clearConversations(Conversation.ConversationType... conversationTypes) {
        return RongIMClient.getInstance().clearConversations(conversationTypes);
    }

    public void addToBlacklist(final String userId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().addToBlacklist(userId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.AddToBlacklistEvent(userId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void removeFromBlacklist(final String userId, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().removeFromBlacklist(userId, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                RongContext.getInstance().getEventBus().post(new Event.RemoveFromBlacklistEvent(userId));
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void getBlacklistStatus(String userId, RongIMClient.ResultCallback<RongIMClient.BlacklistStatus> callback) {
        RongIMClient.getInstance().getBlacklistStatus(userId, callback);
    }

    public void getBlacklist(RongIMClient.GetBlacklistCallback callback) {
        RongIMClient.getInstance().getBlacklist(callback);
    }

    public void setNotificationQuietHours(final String startTime, final int spanMinutes, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().setNotificationQuietHours(startTime, spanMinutes, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                MessageNotificationManager.getInstance().setNotificationQuietHours(startTime, spanMinutes);
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void removeNotificationQuietHours(final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().removeNotificationQuietHours(new RongIMClient.OperationCallback() {
            public void onSuccess() {
                MessageNotificationManager.getInstance().setNotificationQuietHours((String)null, 0);
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void getNotificationQuietHours(final RongIMClient.GetNotificationQuietHoursCallback callback) {
        RongIMClient.getInstance().getNotificationQuietHours(new RongIMClient.GetNotificationQuietHoursCallback() {
            public void onSuccess(String startTime, int spanMinutes) {
                MessageNotificationManager.getInstance().setNotificationQuietHours(startTime, spanMinutes);
                RongIM.notificationQuiteHoursConfigured = true;
                if (callback != null) {
                    callback.onSuccess(startTime, spanMinutes);
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    public void getPublicServiceProfile(Conversation.PublicServiceType publicServiceType, String publicServiceId, RongIMClient.ResultCallback<PublicServiceProfile> callback) {
        RongIMClient.getInstance().getPublicServiceProfile(publicServiceType, publicServiceId, callback);
    }

    public void searchPublicService(RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback) {
        RongIMClient.getInstance().searchPublicService(searchType, keywords, callback);
    }

    public void searchPublicServiceByType(Conversation.PublicServiceType publicServiceType, RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback) {
        RongIMClient.getInstance().searchPublicServiceByType(publicServiceType, searchType, keywords, callback);
    }

    public void subscribePublicService(Conversation.PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().subscribePublicService(publicServiceType, publicServiceId, callback);
    }

    public void unsubscribePublicService(Conversation.PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().unsubscribePublicService(publicServiceType, publicServiceId, callback);
    }

    public void getPublicServiceList(RongIMClient.ResultCallback<PublicServiceProfileList> callback) {
        RongIMClient.getInstance().getPublicServiceList(callback);
    }

    public void syncUserData(UserData userData, final RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().syncUserData(userData, new RongIMClient.OperationCallback() {
            public void onSuccess() {
                if (callback != null) {
                    callback.onSuccess();
                }

            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                if (callback != null) {
                    callback.onError(errorCode);
                }

            }
        });
    }

    /** @deprecated */
    @Deprecated
    public void setRequestPermissionListener(RongIM.RequestPermissionsListener listener) {
        RongContext.getInstance().setRequestPermissionListener(listener);
    }

    public void recordNotificationEvent(String pushId) {
        RongPushClient.recordNotificationEvent(pushId);
    }

    private MessageContent setMessageAttachedUserInfo(MessageContent content) {
        if (RongContext.getInstance().getUserInfoAttachedState() && content.getUserInfo() == null) {
            String userId = getInstance().getCurrentUserId();
            UserInfo info = RongContext.getInstance().getCurrentUserInfo();
            if (info == null) {
                info = RongUserInfoManager.getInstance().getUserInfo(userId);
            }

            if (info != null) {
                content.setUserInfo(info);
            }
        }

        return content;
    }

    private Message filterSendMessage(Conversation.ConversationType conversationType, String targetId, MessageContent messageContent) {
        Message message = new Message();
        message.setConversationType(conversationType);
        message.setTargetId(targetId);
        message.setContent(messageContent);
        if (RongContext.getInstance().getOnSendMessageListener() != null) {
            message = RongContext.getInstance().getOnSendMessageListener().onSend(message);
        }

        return message;
    }

    private Message filterSendMessage(Message message) {
        if (RongContext.getInstance().getOnSendMessageListener() != null) {
            message = RongContext.getInstance().getOnSendMessageListener().onSend(message);
        }

        return message;
    }

    private void filterSentMessage(Message message, RongIMClient.ErrorCode errorCode) {
        RongIM.SentMessageErrorCode sentMessageErrorCode = null;
        boolean isExecute = false;
        if (RongContext.getInstance().getOnSendMessageListener() != null) {
            if (errorCode != null) {
                sentMessageErrorCode = RongIM.SentMessageErrorCode.setValue(errorCode.getValue());
            }

            isExecute = RongContext.getInstance().getOnSendMessageListener().onSent(message, sentMessageErrorCode);
        }

        MessageContent content;
        MessageTag tag;
        if (errorCode != null && !isExecute) {
            if (errorCode.equals(RongIMClient.ErrorCode.NOT_IN_DISCUSSION) || errorCode.equals(RongIMClient.ErrorCode.NOT_IN_GROUP) || errorCode.equals(RongIMClient.ErrorCode.NOT_IN_CHATROOM) || errorCode.equals(RongIMClient.ErrorCode.REJECTED_BY_BLACKLIST) || errorCode.equals(RongIMClient.ErrorCode.FORBIDDEN_IN_GROUP) || errorCode.equals(RongIMClient.ErrorCode.FORBIDDEN_IN_CHATROOM) || errorCode.equals(RongIMClient.ErrorCode.KICKED_FROM_CHATROOM)) {
                InformationNotificationMessage informationMessage = null;
                if (errorCode.equals(RongIMClient.ErrorCode.NOT_IN_DISCUSSION)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_info_not_in_discussion));
                } else if (errorCode.equals(RongIMClient.ErrorCode.NOT_IN_GROUP)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_info_not_in_group));
                } else if (errorCode.equals(RongIMClient.ErrorCode.NOT_IN_CHATROOM)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_info_not_in_chatroom));
                } else if (errorCode.equals(ErrorCode.REJECTED_BY_BLACKLIST)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_rejected_by_blacklist_prompt));
                } else if (errorCode.equals(ErrorCode.FORBIDDEN_IN_GROUP)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_info_forbidden_to_talk));
                } else if (errorCode.equals(ErrorCode.FORBIDDEN_IN_CHATROOM)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_forbidden_in_chatroom));
                } else if (errorCode.equals(ErrorCode.KICKED_FROM_CHATROOM)) {
                    informationMessage = InformationNotificationMessage.obtain(mContext.getString(R.string.rc_kicked_from_chatroom));
                }

                this.insertMessage(message.getConversationType(), message.getTargetId(), message.getSenderUserId(), informationMessage, (RongIMClient.ResultCallback)null);
            }

            content = message.getContent();
            tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
            if (tag != null && (tag.flag() & 1) == 1) {
                RongContext.getInstance().getEventBus().post(new Event.OnMessageSendErrorEvent(message, errorCode));
            }
        } else if (message != null) {
            content = message.getContent();
            tag = (MessageTag)content.getClass().getAnnotation(MessageTag.class);
            if (tag != null && (tag.flag() & 1) == 1) {
                RongContext.getInstance().getEventBus().post(message);
            }
        }

    }

    public static void setServerInfo(String naviServer, String fileServer) {
        if (TextUtils.isEmpty(naviServer)) {
            RLog.e(TAG, "setServerInfo naviServer should not be null.");
            throw new IllegalArgumentException("naviServer should not be null.");
        } else {
            RongIMClient.setServerInfo(naviServer, fileServer);
        }
    }

    public static void setStatisticDomain(String domain) {
        RongIMClient.setStatisticDomain(domain);
    }

    public void setPublicServiceMenuClickListener(IPublicServiceMenuClickListener menuClickListener) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setPublicServiceMenuClickListener(menuClickListener);
        }

    }

    /** @deprecated */
    @Deprecated
    public void recallMessage(Message message) {
        this.recallMessage(message, "");
    }

    public void recallMessage(final Message message, String pushContent) {
        RongIMClient.getInstance().recallMessage(message, pushContent, new RongIMClient.ResultCallback<RecallNotificationMessage>() {
            public void onSuccess(RecallNotificationMessage recallNotificationMessage) {
                RongContext.getInstance().getEventBus().post(new Event.MessageRecallEvent(message.getMessageId(), recallNotificationMessage, true));
            }

            public void onError(RongIMClient.ErrorCode errorCode) {
                RLog.d(RongIM.TAG, "recallMessage errorCode = " + errorCode.getValue());
            }
        });
    }

    public void sendMediaMessage(Message message, String pushContent, String pushData, final IRongCallback.ISendMediaMessageCallback callback) {
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            this.setMessageAttachedUserInfo(message.getContent());
            final RongIMClient.ResultCallback.Result<Event.OnReceiveMessageProgressEvent> result = new RongIMClient.ResultCallback.Result();
            result.t = new Event.OnReceiveMessageProgressEvent();
            IRongCallback.ISendMediaMessageCallback sendMessageCallback = new IRongCallback.ISendMediaMessageCallback() {
                public void onProgress(Message message, int progress) {
                    if (result.t != null) {
                        ((Event.OnReceiveMessageProgressEvent)result.t).setMessage(message);
                        ((Event.OnReceiveMessageProgressEvent)result.t).setProgress(progress);
                        RongContext.getInstance().getEventBus().post(result.t);
                        if (callback != null) {
                            callback.onProgress(message, progress);
                        }

                    }
                }

                public void onAttached(Message message) {
                    RongContext.getInstance().getEventBus().post(message);
                    if (callback != null) {
                        callback.onAttached(message);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }

                public void onCanceled(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onCanceled(message);
                    }

                }
            };
            RongIMClient.getInstance().sendMediaMessage(message, pushContent, pushData, sendMessageCallback);
        }
    }

    public void sendMediaMessage(Message message, String pushContent, String pushData, final IRongCallback.ISendMediaMessageCallbackWithUploader callback) {
        Message temp = this.filterSendMessage(message);
        if (temp != null) {
            if (temp != message) {
                message = temp;
            }

            this.setMessageAttachedUserInfo(message.getContent());
            IRongCallback.ISendMediaMessageCallbackWithUploader sendMediaMessageCallbackWithUploader = new IRongCallback.ISendMediaMessageCallbackWithUploader() {
                public void onAttached(Message message, IRongCallback.MediaMessageUploader uploader) {
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    if (callback != null) {
                        callback.onAttached(message, uploader);
                    }

                }

                public void onProgress(Message message, int progress) {
                    RongIMClient.ResultCallback.Result<Event.OnReceiveMessageProgressEvent> result = new RongIMClient.ResultCallback.Result();
                    result.t = new Event.OnReceiveMessageProgressEvent();
                    ((Event.OnReceiveMessageProgressEvent)result.t).setMessage(message);
                    ((Event.OnReceiveMessageProgressEvent)result.t).setProgress(progress);
                    RongContext.getInstance().getEventBus().post(result.t);
                    if (callback != null) {
                        callback.onProgress(message, progress);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }

                public void onCanceled(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onCanceled(message);
                    }

                }
            };
            RongIMClient.getInstance().sendMediaMessage(message, pushContent, pushData, sendMediaMessageCallbackWithUploader);
        }
    }

    public void cancelDownloadMediaMessage(Message message, RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().cancelDownloadMediaMessage(message, callback);
    }

    public void cancelSendMediaMessage(Message message, RongIMClient.OperationCallback callback) {
        RongIMClient.getInstance().cancelSendMediaMessage(message, callback);
    }

    public void setReadReceiptConversationTypeList(Conversation.ConversationType... types) {
        if (RongContext.getInstance() != null) {
            RongContext.getInstance().setReadReceiptConversationTypeList(types);
        }

    }

    public void sendDirectionalMessage(Conversation.ConversationType type, String targetId, MessageContent content, String[] userIds, String pushContent, String pushData, final IRongCallback.ISendMessageCallback callback) {
        Message message = Message.obtain(targetId, type, content);
        Message filterMsg = this.filterSendMessage(message);
        if (filterMsg == null) {
            RLog.w(TAG, "sendDirectionalMessage: 因在 onSend 中消息被过滤为 null，取消发送。");
        } else {
            if (filterMsg != message) {
                message = filterMsg;
            }

            message.setContent(this.setMessageAttachedUserInfo(message.getContent()));
            RongIMClient.getInstance().sendDirectionalMessage(type, targetId, content, userIds, pushContent, pushData, new IRongCallback.ISendMessageCallback() {
                public void onAttached(Message message) {
                    MessageTag tag = (MessageTag)message.getContent().getClass().getAnnotation(MessageTag.class);
                    if (tag != null && (tag.flag() & 1) == 1) {
                        RongContext.getInstance().getEventBus().post(message);
                    }

                    if (callback != null) {
                        callback.onAttached(message);
                    }

                }

                public void onSuccess(Message message) {
                    RongIM.this.filterSentMessage(message, (RongIMClient.ErrorCode)null);
                    if (callback != null) {
                        callback.onSuccess(message);
                    }

                }

                public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                    RongIM.this.filterSentMessage(message, errorCode);
                    if (callback != null) {
                        callback.onError(message, errorCode);
                    }

                }
            });
        }
    }

    /** @deprecated */
    @Deprecated
    public void setNotificationQuiteHoursConfigured(boolean notificationQuiteHoursConfigured) {
        RongIM var10000 = RongIM.SingletonHolder.sRongIM;
        notificationQuiteHoursConfigured = notificationQuiteHoursConfigured;
    }

    public boolean isNotificationQuiteHoursConfigured() {
        return notificationQuiteHoursConfigured;
    }

    public void setMessageInterceptor(RongIM.MessageInterceptor messageInterceptor) {
        messageInterceptor = messageInterceptor;
    }

    public interface MessageInterceptor {
        boolean intercept(Message var1);
    }

    /** @deprecated */
    @Deprecated
    public interface RequestPermissionsListener {
        /** @deprecated */
        @Deprecated
        void onPermissionRequest(String[] var1, int var2);
    }

    public interface OnReceiveUnreadCountChangedListener {
        void onMessageIncreased(int var1);
    }

    public static enum SentMessageErrorCode {
        UNKNOWN(-1, "Unknown error."),
        NOT_IN_DISCUSSION(21406, "not_in_discussion"),
        NOT_IN_GROUP(22406, "not_in_group"),
        FORBIDDEN_IN_GROUP(22408, "forbidden_in_group"),
        NOT_IN_CHATROOM(23406, "not_in_chatroom"),
        REJECTED_BY_BLACKLIST(405, "rejected by blacklist"),
        NOT_FOLLOWED(29106, "not followed");

        private int code;
        private String msg;

        private SentMessageErrorCode(int code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public int getValue() {
            return this.code;
        }

        public String getMessage() {
            return this.msg;
        }

        public static RongIM.SentMessageErrorCode setValue(int code) {
            RongIM.SentMessageErrorCode[] var1 = values();
            int var2 = var1.length;

            for(int var3 = 0; var3 < var2; ++var3) {
                RongIM.SentMessageErrorCode c = var1[var3];
                if (code == c.getValue()) {
                    return c;
                }
            }

            RLog.d("RongIMClient", "SentMessageErrorCode---ErrorCode---code:" + code);
            return UNKNOWN;
        }
    }

    public interface OnSendMessageListener {
        Message onSend(Message var1);

        boolean onSent(Message var1, RongIM.SentMessageErrorCode var2);
    }

    public interface OnSelectMemberListener {
        void startSelectMember(Context var1, Conversation.ConversationType var2, String var3);
    }

    public interface PublicServiceProfileProvider {
        PublicServiceProfile getPublicServiceProfile(Conversation.PublicServiceType var1, String var2);
    }

    public interface GroupInfoProvider {
        Group getGroupInfo(String var1);
    }

    public interface GroupUserInfoProvider {
        GroupUserInfo getGroupUserInfo(String var1, String var2);
    }

    public interface UserInfoProvider {
        UserInfo getUserInfo(String var1);
    }

    public interface ConversationListBehaviorListener {
        boolean onConversationPortraitClick(Context var1, Conversation.ConversationType var2, String var3);

        boolean onConversationPortraitLongClick(Context var1, Conversation.ConversationType var2, String var3);

        boolean onConversationLongClick(Context var1, View var2, UIConversation var3);

        boolean onConversationClick(Context var1, View var2, UIConversation var3);
    }

    public interface ConversationClickListener {
        boolean onUserPortraitClick(Context var1, Conversation.ConversationType var2, UserInfo var3, String var4);

        boolean onUserPortraitLongClick(Context var1, Conversation.ConversationType var2, UserInfo var3, String var4);

        boolean onMessageClick(Context var1, View var2, Message var3);

        boolean onMessageLinkClick(Context var1, String var2, Message var3);

        boolean onMessageLongClick(Context var1, View var2, Message var3);
    }

    /** @deprecated */
    public interface ConversationBehaviorListener {
        boolean onUserPortraitClick(Context var1, Conversation.ConversationType var2, UserInfo var3);

        boolean onUserPortraitLongClick(Context var1, Conversation.ConversationType var2, UserInfo var3);

        boolean onMessageClick(Context var1, View var2, Message var3);

        boolean onMessageLinkClick(Context var1, String var2);

        boolean onMessageLongClick(Context var1, View var2, Message var3);
    }

    public interface PublicServiceBehaviorListener {
        boolean onFollowClick(Context var1, PublicServiceProfile var2);

        boolean onUnFollowClick(Context var1, PublicServiceProfile var2);

        boolean onEnterConversationClick(Context var1, PublicServiceProfile var2);
    }

    public interface LocationProvider {
        void onStartLocation(Context var1, RongIM.LocationProvider.LocationCallback var2);

        public interface LocationCallback {
            void onSuccess(LocationMessage var1);

            void onFailure(String var1);
        }
    }

    public interface IGroupMemberCallback {
        void onGetGroupMembersResult(List<UserInfo> var1);
    }

    public interface IGroupMembersProvider {
        void getGroupMembers(String var1, RongIM.IGroupMemberCallback var2);
    }

    static class SingletonHolder {
        static RongIM sRongIM = new RongIM();

        SingletonHolder() {
        }
    }
}

